import type { App, Directive } from 'vue';

import { hasPermiDirective, hasRoleDirective, hasRoleTypeDirective, stopPropagation } from './permission';
import elDragDialog from './el-drag-dialog';

const deirectives: {
  [key: string]: Directive | unknown;
} = {
  hasPermi: hasPermiDirective,
  hasRole: hasRoleDirective,
  hasRoleType: hasRoleTypeDirective,
  stopPropagation: stopPropagation,
  'el-drag-dialog': elDragDialog
};

// 全局注册 directive
// export function setupDirective(app: App<Element>) {
//   // 使 v-hasPerm 在所有组件中都可用
//   app.directive('hasPerm', hasPerm);
// }

export default {
  install(app: any) {
    Object.keys(deirectives).forEach((key: string) => {
      app.directive(key, deirectives[key] as Directive);
    });
  }
};
